﻿<phone:PhoneApplicationPage 
    x:Class="AllTalk.ChatPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    d:DataContext="{d:DesignData SampleData/ChatViewModelSampleData.xaml}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    mc:Ignorable="d" d:DesignHeight="768" d:DesignWidth="480"
    shell:SystemTray.IsVisible="True">

    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="Transparent" >
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="80"/>
        </Grid.RowDefinitions>
        <!--TitlePanel contains the name of the application and page title-->
        <StackPanel Grid.Row="0" Margin="12,17,0,28" Orientation="Horizontal">
            <Image Stretch="Uniform" Source="{Binding Image}" MaxWidth="100"></Image>     
            <StackPanel Grid.Row="0" >
                <TextBlock x:Name="PageTitle" Text="{Binding Title}" Style="{StaticResource PhoneTextBlockBase}"/>
                <TextBlock x:Name="PageSubtitle" Text="{Binding Subtitle}" Style="{StaticResource PhoneTextBlockBase}"/>
                <TextBlock Text="{Binding Presence}" Style="{StaticResource PhoneTextBlockBase}"/>
                <TextBlock x:Name="Status" Text="{Binding Status}"  Style="{StaticResource PhoneTextBlockBase}" Foreground="Red"/>
            </StackPanel>
        </StackPanel>
        <ListBox 
                 x:Name="ChatList"
                 ItemsSource="{Binding ChatMessageViewModels}"
                 Grid.Row="1"
                VerticalAlignment="Bottom">            
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Border 
                        Background="White"
                        CornerRadius="10"
                        Margin="{Binding Margin}">
                        <StackPanel MinWidth="380">
                        <TextBlock
                                  Text="{Binding Message}"
                                  TextWrapping="Wrap" 
                                  Style="{StaticResource PhoneTextLargeStyle}"
                                  Foreground="Black"
                                  TextAlignment="{Binding Alignment}" />
                        <TextBlock 
                            Text="{Binding Timestamp}"
                                   Foreground="Gray"
                                   Style="{StaticResource PhoneTextSubtleStyle}"
                                   TextAlignment="{Binding Alignment}"/>
                        </StackPanel>
                    </Border>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
        <TextBox 
            x:Name="MessageTextBox"
            Text="{Binding Message}"
            Grid.Row="2"
            InputScope="Chat"
            GotFocus="TextBox_GotFocus"
            LostFocus="TextBox_LostFocus"
            TextChanged="MessageTextBox_TextChanged"></TextBox>
    </Grid>
 
    <!--Sample code showing usage of ApplicationBar-->
    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="False" IsMenuEnabled="True">
            <shell:ApplicationBarIconButton
                x:Name="SendMessage"
                IconUri="/Images/appbar_button1.png" 
                Text="Button 1" 
                Click="SendMessage_Click"
                IsEnabled="True" />
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>

</phone:PhoneApplicationPage>
